package com.itheima.core.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.itheima.core.dao.user.BuyerDao;
import com.itheima.core.pojo.user.Buyer;
import com.itheima.core.pojo.user.BuyerQuery;

/**
 * @author zhang.cheng
 *
 *         2017年4月6日
 */
@Service("buyerService")
@Transactional
public class BuyerServiceImpl implements BuyerService {

	@Autowired
	private BuyerDao buyerDao;

	@Override
	public Buyer selectBuyerByUsername(String username) {
		BuyerQuery buyerQuery = new BuyerQuery();
		buyerQuery.createCriteria().andUsernameEqualTo(username);
		List<Buyer> buyerList = buyerDao.selectByExample(buyerQuery);
		if (buyerList != null && buyerList.size() > 0) {

			return buyerList.get(0);
		} else {
			return null;
		}
	}

}
